home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / LinAlg 3.1 / LinAlg / math_num.h < prev    next >
Encoding:
Text File  |  1995-12-21  |  2.9 KB  |  101 lines  |  [TEXT/ALFA]

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /*
  3.  ************************************************************************
  4.  *
  5.  *              Numerical Math Package
  6.  *
  7.  * The present package implements various algorithms of Numerical Math
  8.  *
  9.  * $Id: math_num.h,v 3.1 1995/02/07 15:08:22 oleg Exp oleg $
  10.  *
  11.  ************************************************************************
  12.  */
  13.  
  14. #ifndef __GNUC__
  15. #pragma once
  16. #endif
  17. #ifndef _math_num_h
  18. #define _math_num_h 1
  19.  
  20. #pragma interface
  21.  
  22. #include "myenv.h"
  23. #include <math.h>
  24. #include "builtin.h"
  25. #include "std.h"
  26.  
  27. /*
  28.  *------------------------------------------------------------------------
  29.  *                Some constants
  30.  * Compile and run the program epsilon.c to determine the values below for
  31.  * your computer
  32.  */
  33.  
  34. #define EPSILON        2.22045e-16    // DBL_EPSILON
  35. #define SQRT_EPSILON    1.49012e-08
  36.  
  37. /*
  38.  *------------------------------------------------------------------------
  39.  *        Brent's minimum and zero finders for 
  40.  *          a function of a single argument
  41.  */
  42.  
  43.                 // Obtain a zero of function f
  44.                 // over the range [ax,bx] with the
  45.                 // accuracy tol.
  46. double zeroin(const double ax, const double bx, 
  47.           double (*f)(const double x), const double tol=EPSILON);
  48.  
  49.                 // Find a minimum of function f
  50.                 // over the range [a,b] with the
  51.                 // accuracy tol.
  52.                 // Returns an approx. to the min location
  53. double fminbr(const double a, const double b, 
  54.           double (*f)(const double x), const double tol=EPSILON);
  55.  
  56. class Vector;            // Opaque class used by the routines below
  57.  
  58. /*
  59.  *------------------------------------------------------------------------
  60.  *            Interpolation of the function
  61.  *            specified in the tabular form
  62.  */
  63.  
  64.  
  65.                 // Aitken-Lagrange interpolation to the
  66.                 // point q over the table of function values
  67.                 // y[i] = y(x[i]), i = y.lwb..y.upb
  68.  
  69.                 // Uniform mesh x[i] = x0 + s*(i-y.lwb)
  70. double ali(const double q, const double x0, const double s, const Vector& y);
  71.                 // Nonuniform grid with nodes in x[i]
  72. double ali(const double q, const Vector& x, const Vector& y);
  73.  
  74. /*
  75.  *------------------------------------------------------------------------
  76.  *            Multi-dimensional minimization
  77.  */
  78.  
  79.                 // Find a local minimum of a given
  80.                 // function by the Hook-Jeevse method
  81. double hjmin(                // Return the function value at min
  82.     Vector& b,            // Input: initial guess to min loc
  83.                     // Output: loc for the min found
  84.      Vector& h,            // Input: initial values for the
  85.                      //       steps along each b(i)
  86.                      // Output: final steps right before
  87.                      //       the termination
  88.      double (*f)(const Vector& x)    // Procedure to compute a function
  89.                      // value at the specified point
  90.         );
  91.  
  92.  
  93.                     // The same as above with the only difference
  94.                     // initial steps are given to be the same
  95.                     // along every direction. The final steps
  96.                     // aren't reported back though
  97. double hjmin(Vector& b,    const double h0,
  98.           double (*f)(const Vector& x));
  99.  
  100. #endif
  101.